package zhtt.example.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.loadbalancer.LoadBalancerClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class TestController {

    private final String serviceName="microservices-application";

    @Autowired
    private LoadBalancerClient loadBalancerClient;

    @GetMapping("/test-load-balancer")
    public String testLoadBalancer() {
        Object serviceInstance = loadBalancerClient.choose(serviceName);
        return "LoadBalancerClient: " + loadBalancerClient;
    }
}
